package cn.belong.jk.service;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.belong.jk.dao.FactoryDao;
import cn.belong.jk.entity.Factory;

@Service("factoryService")
public class FatoryServiceImpl implements FactoryService {

    @Autowired
    FactoryDao factoryDao; 
    
	public List<Factory> find(Map paraMap) {
		return factoryDao.find(paraMap);  
	}

	public Factory get(Serializable id) {
		return factoryDao.get(id);  
	}

	public void insert(Factory entity) {
	    //设置UUID  
		entity.setId(UUID.randomUUID().toString());  
		entity.setState("1");//默认启用
	    factoryDao.insert(entity);  

	}

	public void update(Factory entity) {
		factoryDao.update(entity);  

	}

	public void deleteById(Serializable id) {
		 factoryDao.deleteById(id);

	}

	public void delete(Serializable[] ids) {
		factoryDao.delete(ids);

	}

	public void start(Serializable[] ids) {
	     Map map=new HashMap();  
	     map.put("state",1);//1启用  
	     map.put("ids", ids);  
	       
	     factoryDao.updateState(map); 
		
	}

	public void stop(Serializable[] ids) {
	     Map map=new HashMap();  
	     map.put("state",0);//1启用  
	     map.put("ids", ids);  
	       
	     factoryDao.updateState(map); 
		
	}

	public List<Factory> getFactoryList() {
	    Map<String,Object> paraMap=new HashMap<String,Object>();  
	    paraMap.put("state", 1);//1启用，代表只查询启用的生产厂家  
	          
	    return factoryDao.find(paraMap);  
	}


}
